package com.qhy.service.imp;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.qhy.mapper.TbAdminMapper;
import com.qhy.pojo.TbAdmin;
import com.qhy.pojo.TbAdminExample;
import com.qhy.pojo.TbAdminExample.Criteria;
import com.qhy.service.IAdminService;

@Service
public class AdminService implements IAdminService {
	
	@Resource
	private TbAdminMapper tbAdminMapper;
	
	
	public TbAdmin login(TbAdmin admin) {
		TbAdminExample tbAdminExample = new TbAdminExample();
		Criteria createCriteria = tbAdminExample.createCriteria();
		createCriteria.andAdminNameEqualTo(admin.getAdminName());
		createCriteria.andAdminPasswordEqualTo(admin.getAdminPassword());
		List<TbAdmin> selectByExample = tbAdminMapper.selectByExample(tbAdminExample);
		return selectByExample.size()>0?selectByExample.get(0):null;
	}


	public List<TbAdmin> query(TbAdminExample adminExample) {
		return tbAdminMapper.selectByExample(adminExample);
	}


	public int addAdmin(TbAdmin admin) {
		admin.setAdminStatus(0);
		return tbAdminMapper.insert(admin);
	}


	public Integer delAdmin(Integer a_id) {
		return tbAdminMapper.deleteByPrimaryKey(a_id);
	}
	
	
	
	
}
